package com.zhongcw.test.spring.boot.send.request.controller;


import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.nio.charset.Charset;
import java.util.Date;

/**
 * @author ZCW
 * @createTime 2017/12/13
 * @lastUpdateTime 2017/12/13 ZCW
 */
@RestController
public class SimpleController {

    int t1=10;
    Integer t2 = 10;
    Integer t3=new Integer(10);

    @RequestMapping("/charset")
    public Object charset(String param, HttpServletRequest request, HttpServletResponse response, HttpSession session) {

        if (StringUtils.isEmpty(param))
            return new String("param 为空！".getBytes(Charset.forName("UTF-8")));

        System.out.println("param = " + param);

        param = new String(param.getBytes(Charset.forName("UTF-8")));

        System.out.println("return = " + param);

        return param;

    }

    @RequestMapping
    public Object index() throws InterruptedException {
        Thread.sleep(1000*5);
        System.out.println(new Date());
        return t1;
    }

}
